import api from './index'
import {
  axios
} from '@/utils/request'

// 查询xbd供应商信息
export function getXbdServers(data) {
  return axios({
    url: `agent/enterprise/getXbdServers`,
    method: 'post',
    data: data
  })
}

export function getEnterpriseList(parameter) {
  return axios({
    url: api.EnterpriseList,
    method: 'get',
    params: parameter
  })
}

export function getEnterpriseDetail(enterpriseId) {
  return axios({
    url: api.EnterpriseDetail + enterpriseId,
    method: 'get'
  })
}

export function addEnterprise(parameter) {
  return axios({
    url: api.Enterprise,
    method: 'post',
    data: parameter
  })
}

export function updateEnterprise(parameter) {
  return axios({
    url: api.Enterprise,
    method: 'put',
    data: parameter
  })
}


export function freezeEnterprise(parameter) {
  return axios({
    url: api.EnterpriseFreeze + parameter.enterpriseId,
    method: 'put',
    params: parameter
  })
}

export function freezeEnterprise1(parameter) {
  return axios({
    url: `agent/agentUser/freeze/${parameter.agentId}`,
    method: 'put',
    params: parameter
  })
}

export function getEnterpriseOptions() {
  return axios({
    url: api.EnterpriseOptions,
    method: 'get'
  })
}

export function getUserList(parameter) {
  return axios({
    url: api.UserList,
    method: 'get',
    params: parameter
  })
}
//查询验收记录的服务者
export function getServers(reportId) {
  return axios({
    url: `/project/${reportId}/server`,
    method: 'get'
  })
}

export function updateUser(individualUserId, parameter) {
  return axios({
    url: api.User + individualUserId,
    method: 'put',
    data: parameter
  })
}

export function getSignInfoByUserId(individualUserId) {
  return axios({
    url: `${api.User}${individualUserId}${api.UserSignInfo}`,
    method: 'get'
  })
}

export function updateSignStatusByUserId(individualUserId) {
  return axios({
    url: api.UserSignStatusUpdate + individualUserId,
    method: 'post'
  })
}

export function getProjectList(parameter) {
  return axios({
    url: api.ProjectList,
    method: 'get',
    params: parameter
  })
}

export function getProjectMembers(projectId) {
  return axios({
    url: `/project/${projectId}/members`,
    method: 'get'
  })
}

export function getProjectDetail(projectId) {
  return axios({
    url: `/agent/project/${projectId}/detail`,
    method: 'get',
    params: {
      projectId
    }
  })
}

export function getProjectReports(projectId) {
  return axios({
    url: `/project/${projectId}/reports`,
    method: 'get',
    params: {
      projectId
    }
  })
}

export function getProjectApplicant(projectId) {
  return axios({
    url: `/project/${projectId}/applicant`,
    method: 'get',
    params: {
      projectId
    }
  })
}

export function getProjectApplicantTrace(projectId, individualUserId) {
  return axios({
    url: `/agent/project/${projectId}/${individualUserId}/trace`,
    method: 'get'
  })
}

export function getProjectMemberDetail(projectId, projectMemberId) {
  return axios({
    url: `/agent/projectMember/${projectId}/${projectMemberId}/detail`,
    method: 'get'
  })
}

export function getCategoryChild(parentId) {
  return axios({
    url: api.CategoryChild + parentId,
    method: 'get'
  })
}

export function addCategoryChild(parameter) {
  return axios({
    url: api.CategoryCreate,
    method: 'post',
    data: parameter
  })
}

export function updateCategoryChild(parameter) {
  return axios({
    url: api.CategoryUpdate,
    method: 'post',
    data: parameter
  })
}

export function deleteCategory(categoryId) {
  return axios({
    url: api.CategoryDelete + categoryId,
    method: 'delete'
  })
}

export function uploadImage(data) {
  return axios({
    url: api.UploadImage,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    transformRequest: [
      function (data) {
        return data
      }
    ]
  })
}

// 生成OSS的访问URL
export function getUrl(parameter) {
  return axios({
    url: '/file/getUrl',
    method: 'get',
    params: parameter
  })
}

// to be deleted
export function getRoleList(parameter) {
  return axios({
    url: api.role,
    method: 'get',
    params: parameter
  })
}

export function getServiceList(parameter) {
  return axios({
    url: api.service,
    method: 'get',
    params: parameter
  })
}

export function getPermissions(parameter) {
  return axios({
    url: api.permissionNoPager,
    method: 'get',
    params: parameter
  })
}

export function getOrgTree(parameter) {
  return axios({
    url: api.orgTree,
    method: 'get',
    params: parameter
  })
}

// id == 0 add     post
// id != 0 update  put
export function saveService(parameter) {
  return axios({
    url: api.service,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function getBillList(parameter) {
  return axios({
    url: api.BillList,
    method: 'get',
    params: parameter
  })
}

export function getSettlementList(parameter) {
  return axios({
    url: api.SettlementList,
    method: 'get',
    params: parameter
  })
}

export function getPaymentList(parameter) {
  return axios({
    url: api.PaymentList,
    method: 'get',
    params: parameter
  })
}

export function getOrderListByBatchId(batchId) {
  return axios({
    url: `${api.BatchOrderList}/${batchId}/orders`,
    method: 'get'
  })
}

export function updateBatchOrOrderStatus(parameter) {
  return axios({
    url: api.UpdateBatchOrOrderStatus,
    method: 'post',
    data: parameter
  })
}

// ProjectSkill
export function getSkillList(categoryId, parameter) {
  return axios({
    url: api.SkillList + categoryId,
    method: 'get',
    params: parameter
  })
}

export function createSkill(parameter) {
  return axios({
    url: api.SkillCreate,
    method: 'post',
    data: parameter
  })
}

export function deleteSkillById(skillId) {
  return axios({
    url: api.SkillDelete + skillId,
    method: 'delete'
  })
}

export function updateSkill(parameter) {
  return axios({
    url: api.SkillCreate,
    method: 'put',
    data: parameter
  })
}
export function resetSign(individualUserId) {
  return axios({
    url: api.userReset + individualUserId,
    method: 'post',
    data: individualUserId
  })
}
export function resetLoginPassword(enterpriseId) {
  return axios({
    url: api.EnterpriseResetPassword + enterpriseId,
    method: 'post',
    data: enterpriseId
  })
}

export function queryInvoiceRecord(data) {
  return axios({
    url: 'taxInvoiceRecordController/getTaxInvoiceRecord',
    method: 'get',
    params: data
  })
}
//物流
export function updateInvoiceRecord(data) {
  return axios({
    url: 'taxInvoiceRecordController/updateInvoiceRecord',
    method: 'post',
    data: data
  })
}

export function queryInvoiceType(data) {
  return axios({
    url: 'InvoiceType/getAllInvoiceType',
    method: 'get',
    data: data
  })
}
//添加发票信息
export function addInvoiceNum(batchId, data) {
  return axios({
    url: `/settle/${ batchId }/invoiceNum`,
    method: 'post',
    data: data
  })
}

//修改开票类目
export function updateInvoiceType(data) {
  return axios({
    url: 'InvoiceType/updateInvoiceType',
    method: 'post',
    data: data
  })
}

//新增开票类目
export function addInvoiceType(data) {
  return axios({
    url: 'InvoiceType/addInvoiceType',
    method: 'post',
    data: data
  })
}
//删除开票类目
export function deleteInvoiceType(id) {
  return axios({
    url: `/InvoiceType/deleteInvoiceType/${id}`,
    method: 'delete'
  })
}
//根据id查询发票信息
export function getInvoiceRecord(id) {
  return axios({
    url: `taxInvoiceRecordController/getInvoiceRecord/${id}`,
    method: 'get'
  })
}

// 上传项目文件 公开
export function uploadProjectFile(data) {
  return axios({
    url: '/file/uploadProjectFile',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    transformRequest: [
      function (data) {
        return data
      }
    ]
  })
}
// 批量上传签名
export function addBatchSignZip(data) {
  return axios({
    url: '/enterprise/addBatchSignZip',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    transformRequest: [
      function (data) {
        return data
      }
    ]
  })
}
///api/settle/{projectId}/batch查询项目的结算批次
export function getBusinessList(projectId) {
  return axios({
    url: `/settle/${projectId}/batch`,
    method: 'get'
  })
}

//代理商
//api/agent/agentUser/list查询代理商
export function getAgentUser(parameter) {
  return axios({
    url: `agent/agentUser/list`,
    method: 'get',
    params: parameter
  })
}
//api/agent/agentUser/save新增代理商
export function addAgentUser(data) {
  return axios({
    url: 'agent/agentUser/save',
    method: 'post',
    data: data
  })
}

// 上传交付附件 服务方提交交付附件专用上传接口 私有
export function uploadDeliveryFile(data) {
  return axios({
    url: '/file/uploadDeliveryFile',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    transformRequest: [
      function (data) {
        return data
      }
    ]
  })
}
//api/agent/agentUser/update更新代理商信息
export function addAgentUpdate(data) {
  return axios({
    url: 'agent/agentUser/update',
    method: 'put',
    data: data
  })
}
//获取行业id
export function getIndustry(parameter) {
  return axios({
    url: `agent/enterprise/industry/${parameter}`,
    method: 'get'
  })
}

//导出发票
export function exportInvoiceZip(data) {
  return axios({
    url: 'invoice/exportInvoiceZip',
    method: 'post',
    data: data
  })
}
// 查询发票文件导出状态
export function exportInvoiceZipResult(parameter) {
  return axios({
    url: `invoice/exportInvoiceZip/result`,
    method: 'get',
    params: parameter
  })
}
//查找本代理的信息
export function getAgent(parameter) {
  return axios({
    url: `agent/agentUser`,
    method: 'get',
    // params: {
    //   userType: 1
    // }
  })
}

//数据中心
export function getHeadInfo(parameter = {}) {
  return axios({
    url: `statistical/headInfo`,
    method: 'get',
    params: parameter
  })
}
export function getOrderInfo(parameter) {
  return axios({
    url: `statistical/orderInfo`,
    method: 'get',
    params: parameter
  })
}
export function getEnOrderInfo(parameter) {
  return axios({
    url: `statistical/enOrderInfo`,
    method: 'get',
    params: parameter
  })
}
export function getOrderRanking(parameter) {
  return axios({
    url: `statistical/orderRanking`,
    method: 'get',
    params: parameter
  })
}

// 查询运营人员
export function getYYsysUsers() {
  return axios({
    url: `agent/enterprise/operationManagers`,
    method: 'get',
    params: {
      userType: 1
    }
  })
}
// 获取验证码
export function getPhoneCode (data) {
  return axios({
    url: `/pub/sms/publicSendVerifyCode?phone=${data.phone}&smsScene=${data.smsScene}`,
    method: 'post'
  })
}
// 验证码登录
export function newCodeLogin (data) {
  return axios({
    url: '/pub/loginByPhoneAndSmsCode',
    method: 'post',
    data: data
  })
}
// 重置支付密码
export function resetPayPassword(enterpriseId) {
  return axios({
      url: '/agent/enterprise/resetPayPassword/' + enterpriseId,
      method: 'post',
      data: enterpriseId
  })
}
// 获取供应商
export function getServerFeeList(data) {
  return axios({
    url: '/agent/enterprise/getXbdServerInfoByServerId',
    method: 'get',
    params: data
  })
}